####Model results####
##a) segmented clientelistic (table X20, models A64-A67)
r5b_m1g_t1_sc <- glm(as.formula(paste("cw_event_g", paste(c(m1g_t1, group_nat_vars, group_unit_vars, unit_vars, nat_vars, "as.factor(region)","as.factor(year)","cw_event_g_peaceyears_l1","I(cw_event_g_peaceyears_l1^2)","I(cw_event_g_peaceyears_l1^3)","cw_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_group, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant_g == 1))
r5b_m1g_t1_sc_cse <- data.frame(cluster.se(r5b_m1g_t1_sc, as.factor(subset(main_group, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant_g == 1)$cowcode))[,2])
r5b_m1g_t1_sf <- glm(as.formula(paste("cw_event_g", paste(c(m1g_t1, group_nat_vars, group_unit_vars, unit_vars, nat_vars, "as.factor(region)","as.factor(year)","cw_event_g_peaceyears_l1","I(cw_event_g_peaceyears_l1^2)","I(cw_event_g_peaceyears_l1^3)","cw_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_group, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant_g == 0))
r5b_m1g_t1_sf_cse <- data.frame(cluster.se(r5b_m1g_t1_sf, as.factor(subset(main_group, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant_g == 0)$cowcode))[,2])
r5b_m1d_t1_sb <- glm(as.formula(paste("cv_event", paste(c(m1d_t1, dyad_nat_vars, dyad_unit_vars, unit_vars, nat_vars,"as.factor(region)","as.factor(year)","cv_event_peaceyears_l1","I(cv_event_peaceyears_l1^2)","I(cv_event_peaceyears_l1^3)","cv_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_dyad, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1))
r5b_m1d_t1_sb_cse <- data.frame(cluster.se(r5b_m1d_t1_sb, as.factor(subset(main_dyad, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode))[, 2])
r5b_m2d_t1_sb <- glm(as.formula(paste("cv_event", paste(c(m2d_t1, dyad_nat_vars, dyad_unit_vars, unit_vars, nat_vars,"as.factor(region)","as.factor(year)","cv_event_peaceyears_l1","I(cv_event_peaceyears_l1^2)","I(cv_event_peaceyears_l1^3)","cv_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_dyad, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1))
r5b_m2d_t1_sb_cse <- data.frame(cluster.se(r5b_m2d_t1_sb, as.factor(subset(main_dyad, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode))[, 2])
stargazer(r5b_m1g_t1_sc, r5b_m1g_t1_sf, r5b_m1d_t1_sb, r5b_m2d_t1_sb, se=c(r5b_m1g_t1_sc_cse, r5b_m1g_t1_sf_cse, r5b_m1d_t1_sb_cse, r5b_m2d_t1_sb_cse), dep.var.labels.include = T, dep.var.labels = c("Civil violence (group)","Communal violence","Communal violence"), model.numbers =F, column.labels = c("Maj. (model A64)", "Min. (model A65)","Maj./min. dyad (model A66)","Maj./min. dyad (model A67)"), omit=c("cowcode|region|factor"), type="text", order=vars.order_gd, title="Table X20. Additional results: segmented clientelistic countries only.", style = "apsr", star.cutoffs = c(.1, .05, .01, .001), star.char = c("†", "*", "**","***"), notes = c("† p<0.1; * p<0.05; ** p<0.01; *** p<0.001; country-clustered SE’s in parentheses; maj. = second-order majority; min. = second-order minority.","The dependent variable is a binary variable equal to one if there is at least one instance of civil/communal violence involving a group/dyad in a given unit.","Region- and year-fixed effects included but not reported."), notes.append=FALSE, covariate.labels = c("Territorial autonomy","Territorial autonomy x included/excluded","Included","Included/excluded","Excluded/excluded","Relative size (state)","Relative size (state, mean)","Relative size (state, diff.)","Relative size (unit)","Relative size (unit, mean)","Relative size (unit, diff.)","Asymmetry", "Population (unit, logged)", "Area (unit, logged)", "Avg. ruggedness (unit)", "Oil in unit", "Distance capital (unit, logged)", "Distance border (unit, logged)","GDP pc. (logged)", "Population (state, logged)","Democracy","Ethnic fractionalization","Election year","Civil violence peace years","Civil violence peace years 2","Civil violence peace years 3","Civil violence spatial lag", "Communal violence peace years", "Communal violence peace years 2", "Communal violence peace years 3","Communal violence spatial lag"), out="../tables/additional_results_tables_appendices/tablex20.txt")
stargazer(r5b_m1g_t1_sc, r5b_m1g_t1_sf, r5b_m1d_t1_sb, r5b_m2d_t1_sb, se=c(r5b_m1g_t1_sc_cse, r5b_m1g_t1_sf_cse, r5b_m1d_t1_sb_cse, r5b_m2d_t1_sb_cse), dep.var.labels.include = T, dep.var.labels = c("Civil violence (group)","Communal violence","Communal violence"), model.numbers =F, column.labels = c("Maj. (model A64)", "Min. (model A65)","Maj./min. dyad (model A66)","Maj./min. dyad (model A67)"), omit=c("cowcode|region|factor"), type="html", order=vars.order_gd, title="Table X20. Additional results: segmented clientelistic countries only.", style = "apsr", star.cutoffs = c(.1, .05, .01, .001), star.char = c("†", "*", "**","***"), notes = c("† p<0.1; * p<0.05; ** p<0.01; *** p<0.001; country-clustered SE’s in parentheses; maj. = second-order majority; min. = second-order minority.","The dependent variable is a binary variable equal to one if there is at least one instance of civil/communal violence involving a group/dyad in a given unit.","Region- and year-fixed effects included but not reported."), notes.append=FALSE, covariate.labels = c("Territorial autonomy","Territorial autonomy x included/excluded","Included","Included/excluded","Excluded/excluded","Relative size (state)","Relative size (state, mean)","Relative size (state, diff.)","Relative size (unit)","Relative size (unit, mean)","Relative size (unit, diff.)","Asymmetry", "Population (unit, logged)", "Area (unit, logged)", "Avg. ruggedness (unit)", "Oil in unit", "Distance capital (unit, logged)", "Distance border (unit, logged)","GDP pc. (logged)", "Population (state, logged)","Democracy","Ethnic fractionalization","Election year","Civil violence peace years","Civil violence peace years 2","Civil violence peace years 3","Civil violence spatial lag", "Communal violence peace years", "Communal violence peace years 2", "Communal violence peace years 3","Communal violence spatial lag"), out="../tables/additional_results_tables_appendices/tablex20.html")
##b) democracies (table X21, models A68-A71)
dem_main_m1g_t1_sc <- glm(as.formula(paste("cw_event_g", paste(c(m1g_t1, group_nat_vars, group_unit_vars, unit_vars, nat_vars, "as.factor(region)","as.factor(year)","cw_event_g_peaceyears_l1","I(cw_event_g_peaceyears_l1^2)","I(cw_event_g_peaceyears_l1^3)","cw_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 1 & politya >= 0.8))
dem_main_m1g_t1_sc_cse <- data.frame(cluster.se(dem_main_m1g_t1_sc, as.factor(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 1 & politya >= 0.8)$cowcode))[,2])
dem_main_m1g_t1_sf <- glm(as.formula(paste("cw_event_g", paste(c(m1g_t1, group_nat_vars, group_unit_vars, unit_vars, nat_vars, "as.factor(region)","as.factor(year)","cw_event_g_peaceyears_l1","I(cw_event_g_peaceyears_l1^2)","I(cw_event_g_peaceyears_l1^3)","cw_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 0 & politya >= 0.8))
dem_main_m1g_t1_sf_cse <- data.frame(cluster.se(dem_main_m1g_t1_sf, as.factor(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 0 & politya >= 0.8)$cowcode))[,2])
dem_main_m1d_t1_sb <- glm(as.formula(paste("cv_event", paste(c(m1d_t1, dyad_nat_vars, dyad_unit_vars, unit_vars, nat_vars,"as.factor(region)","as.factor(year)","cv_event_peaceyears_l1","I(cv_event_peaceyears_l1^2)","I(cv_event_peaceyears_l1^3)","cv_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_dyad, politya >= 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1))
dem_main_m1d_t1_sb_cse <- data.frame(cluster.se(dem_main_m1d_t1_sb, as.factor(subset(main_dyad, politya >= 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode))[, 2])
dem_main_m2d_t1_sb <- glm(as.formula(paste("cv_event", paste(c(m2d_t1, dyad_nat_vars, dyad_unit_vars, unit_vars, nat_vars,"as.factor(region)","as.factor(year)","cv_event_peaceyears_l1","I(cv_event_peaceyears_l1^2)","I(cv_event_peaceyears_l1^3)","cv_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_dyad, politya >= 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1))
dem_main_m2d_t1_sb_cse <- data.frame(cluster.se(dem_main_m2d_t1_sb, as.factor(subset(main_dyad, politya >= 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode))[, 2])
stargazer(dem_main_m1g_t1_sc, dem_main_m1g_t1_sf, dem_main_m1d_t1_sb, dem_main_m2d_t1_sb, se=c(dem_main_m1g_t1_sc_cse, dem_main_m1g_t1_sf_cse, dem_main_m1d_t1_sb_cse, dem_main_m2d_t1_sb_cse), dep.var.labels.include = T, dep.var.labels = c("Civil violence (group)","Communal violence","Communal violence"), model.numbers =F, column.labels = c("Maj. (model A68)", "Min. (model A69)","Maj./min. dyad (model A70)","Maj./min. dyad (model A71)"), omit=c("cowcode|region|factor"), type="text", order=vars.order_gd, title="Table X21. Additional results: democratic countries only.", style = "apsr", star.cutoffs = c(.1, .05, .01, .001), star.char = c("†", "*", "**","***"), notes = c("† p<0.1; * p<0.05; ** p<0.01; *** p<0.001; country-clustered SE’s in parentheses; maj. = second-order majority; min. = second-order minority.","The dependent variable is a binary variable equal to one if there is at least one instance of civil/communal violence involving a group/dyad in a given unit.","Region- and year-fixed effects included but not reported."), notes.append=FALSE, covariate.labels = c("Territorial autonomy","Territorial autonomy x included/excluded","Included","Included/excluded","Excluded/excluded","Relative size (state)","Relative size (state, mean)","Relative size (state, diff.)","Relative size (unit)","Relative size (unit, mean)","Relative size (unit, diff.)","Asymmetry", "Population (unit, logged)", "Area (unit, logged)", "Avg. ruggedness (unit)", "Oil in unit", "Distance capital (unit, logged)", "Distance border (unit, logged)","GDP pc. (logged)", "Population (state, logged)","Democracy","Ethnic fractionalization","Election year","Civil violence peace years","Civil violence peace years 2","Civil violence peace years 3","Civil violence spatial lag", "Communal violence peace years", "Communal violence peace years 2", "Communal violence peace years 3","Communal violence spatial lag"), out="../tables/additional_results_tables_appendices/tablex21.txt")
stargazer(dem_main_m1g_t1_sc, dem_main_m1g_t1_sf, dem_main_m1d_t1_sb, dem_main_m2d_t1_sb, se=c(dem_main_m1g_t1_sc_cse, dem_main_m1g_t1_sf_cse, dem_main_m1d_t1_sb_cse, dem_main_m2d_t1_sb_cse), dep.var.labels.include = T, dep.var.labels = c("Civil violence (group)","Communal violence","Communal violence"), model.numbers =F, column.labels = c("Maj. (model A68)", "Min. (model A69)","Maj./min. dyad (model A70)","Maj./min. dyad (model A71)"), omit=c("cowcode|region|factor"), type="html", order=vars.order_gd, title="Table X21. Additional results: democratic countries only.", style = "apsr", star.cutoffs = c(.1, .05, .01, .001), star.char = c("†", "*", "**","***"), notes = c("† p<0.1; * p<0.05; ** p<0.01; *** p<0.001; country-clustered SE’s in parentheses; maj. = second-order majority; min. = second-order minority.","The dependent variable is a binary variable equal to one if there is at least one instance of civil/communal violence involving a group/dyad in a given unit.","Region- and year-fixed effects included but not reported."), notes.append=FALSE, covariate.labels = c("Territorial autonomy","Territorial autonomy x included/excluded","Included","Included/excluded","Excluded/excluded","Relative size (state)","Relative size (state, mean)","Relative size (state, diff.)","Relative size (unit)","Relative size (unit, mean)","Relative size (unit, diff.)","Asymmetry", "Population (unit, logged)", "Area (unit, logged)", "Avg. ruggedness (unit)", "Oil in unit", "Distance capital (unit, logged)", "Distance border (unit, logged)","GDP pc. (logged)", "Population (state, logged)","Democracy","Ethnic fractionalization","Election year","Civil violence peace years","Civil violence peace years 2","Civil violence peace years 3","Civil violence spatial lag", "Communal violence peace years", "Communal violence peace years 2", "Communal violence peace years 3","Communal violence spatial lag"), out="../tables/additional_results_tables_appendices/tablex21.html")
##c) autocracies (table X22, models A72-A75)
aut_main_m1g_t1_sc <- glm(as.formula(paste("cw_event_g", paste(c(m1g_t1, group_nat_vars, group_unit_vars, unit_vars, nat_vars, "as.factor(region)","as.factor(year)","cw_event_g_peaceyears_l1","I(cw_event_g_peaceyears_l1^2)","I(cw_event_g_peaceyears_l1^3)","cw_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 1 & politya < 0.8))
aut_main_m1g_t1_sc_cse <- data.frame(cluster.se(aut_main_m1g_t1_sc, as.factor(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 1 & politya < 0.8)$cowcode))[,2])
aut_main_m1g_t1_sf <- glm(as.formula(paste("cw_event_g", paste(c(m1g_t1, group_nat_vars, group_unit_vars, unit_vars, nat_vars, "as.factor(region)","as.factor(year)","cw_event_g_peaceyears_l1","I(cw_event_g_peaceyears_l1^2)","I(cw_event_g_peaceyears_l1^3)","cw_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 0 & politya < 0.8))
aut_main_m1g_t1_sf_cse <- data.frame(cluster.se(aut_main_m1g_t1_sf, as.factor(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 0 & politya < 0.8)$cowcode))[,2])
aut_main_m1d_t1_sb <- glm(as.formula(paste("cv_event", paste(c(m1d_t1, dyad_nat_vars, dyad_unit_vars, unit_vars, nat_vars,"as.factor(region)","as.factor(year)","cv_event_peaceyears_l1","I(cv_event_peaceyears_l1^2)","I(cv_event_peaceyears_l1^3)","cv_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_dyad, politya < 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1))
aut_main_m1d_t1_sb_cse <- data.frame(cluster.se(aut_main_m1d_t1_sb, as.factor(subset(main_dyad, politya < 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode))[, 2])
aut_main_m2d_t1_sb <- glm(as.formula(paste("cv_event", paste(c(m2d_t1, dyad_nat_vars, dyad_unit_vars, unit_vars, nat_vars,"as.factor(region)","as.factor(year)","cv_event_peaceyears_l1","I(cv_event_peaceyears_l1^2)","I(cv_event_peaceyears_l1^3)","cv_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_dyad, politya < 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1))
aut_main_m2d_t1_sb_cse <- data.frame(cluster.se(aut_main_m2d_t1_sb, as.factor(subset(main_dyad, politya < 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode))[, 2])
stargazer(aut_main_m1g_t1_sc, aut_main_m1g_t1_sf, aut_main_m1d_t1_sb, aut_main_m2d_t1_sb, se=c(aut_main_m1g_t1_sc_cse, aut_main_m1g_t1_sf_cse, aut_main_m1d_t1_sb_cse, aut_main_m2d_t1_sb_cse), dep.var.labels.include = T, dep.var.labels = c("Civil violence (group)","Communal violence","Communal violence"), model.numbers =F, column.labels = c("Maj. (model A72)", "Min. (model A73)","Maj./min. dyad (model A74)","Maj./min. dyad (model A75)"), omit=c("cowcode|region|factor"), type="text", order=vars.order_gd, title="Table X22. Additional results: autocratic countries only.", style = "apsr", star.cutoffs = c(.1, .05, .01, .001), star.char = c("†", "*", "**","***"), notes = c("† p<0.1; * p<0.05; ** p<0.01; *** p<0.001; country-clustered SE’s in parentheses; maj. = second-order majority; min. = second-order minority.","The dependent variable is a binary variable equal to one if there is at least one instance of civil/communal violence involving a group/dyad in a given unit.","Region- and year-fixed effects included but not reported."), notes.append=FALSE, covariate.labels = c("Territorial autonomy","Territorial autonomy x included/excluded","Included","Included/excluded","Excluded/excluded","Relative size (state)","Relative size (state, mean)","Relative size (state, diff.)","Relative size (unit)","Relative size (unit, mean)","Relative size (unit, diff.)","Asymmetry", "Population (unit, logged)", "Area (unit, logged)", "Avg. ruggedness (unit)", "Oil in unit", "Distance capital (unit, logged)", "Distance border (unit, logged)","GDP pc. (logged)", "Population (state, logged)","Democracy","Ethnic fractionalization","Election year","Civil violence peace years","Civil violence peace years 2","Civil violence peace years 3","Civil violence spatial lag", "Communal violence peace years", "Communal violence peace years 2", "Communal violence peace years 3","Communal violence spatial lag"), out="../tables/additional_results_tables_appendices/tablex22.txt")
stargazer(aut_main_m1g_t1_sc, aut_main_m1g_t1_sf, aut_main_m1d_t1_sb, aut_main_m2d_t1_sb, se=c(aut_main_m1g_t1_sc_cse, aut_main_m1g_t1_sf_cse, aut_main_m1d_t1_sb_cse, aut_main_m2d_t1_sb_cse), dep.var.labels.include = T, dep.var.labels = c("Civil violence (group)","Communal violence","Communal violence"), model.numbers =F, column.labels = c("Maj. (model A72)", "Min. (model A73)","Maj./min. dyad (model A74)","Maj./min. dyad (model A75)"), omit=c("cowcode|region|factor"), type="html", order=vars.order_gd, title="Table X22. Additional results: autocratic countries only.", style = "apsr", star.cutoffs = c(.1, .05, .01, .001), star.char = c("†", "*", "**","***"), notes = c("† p<0.1; * p<0.05; ** p<0.01; *** p<0.001; country-clustered SE’s in parentheses; maj. = second-order majority; min. = second-order minority.","The dependent variable is a binary variable equal to one if there is at least one instance of civil/communal violence involving a group/dyad in a given unit.","Region- and year-fixed effects included but not reported."), notes.append=FALSE, covariate.labels = c("Territorial autonomy","Territorial autonomy x included/excluded","Included","Included/excluded","Excluded/excluded","Relative size (state)","Relative size (state, mean)","Relative size (state, diff.)","Relative size (unit)","Relative size (unit, mean)","Relative size (unit, diff.)","Asymmetry", "Population (unit, logged)", "Area (unit, logged)", "Avg. ruggedness (unit)", "Oil in unit", "Distance capital (unit, logged)", "Distance border (unit, logged)","GDP pc. (logged)", "Population (state, logged)","Democracy","Ethnic fractionalization","Election year","Civil violence peace years","Civil violence peace years 2","Civil violence peace years 3","Civil violence spatial lag", "Communal violence peace years", "Communal violence peace years 2", "Communal violence peace years 3","Communal violence spatial lag"), out="../tables/additional_results_tables_appendices/tablex22.html")
##d) ever violent (table X23, models A76-A79)
viol_ever_main_m1g_t1_sc <- glm(as.formula(paste("cw_event_g", paste(c(m1g_t1, group_nat_vars, group_unit_vars, unit_vars, nat_vars, "as.factor(region)","as.factor(year)","cw_event_g_peaceyears_l1","I(cw_event_g_peaceyears_l1^2)","I(cw_event_g_peaceyears_l1^3)","cw_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 1 & violence_ever == 1))
viol_ever_main_m1g_t1_sc_cse <- data.frame(cluster.se(viol_ever_main_m1g_t1_sc, as.factor(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 1 & violence_ever == 1)$cowcode))[,2])
viol_ever_main_m1g_t1_sf <- glm(as.formula(paste("cw_event_g", paste(c(m1g_t1, group_nat_vars, group_unit_vars, unit_vars, nat_vars, "as.factor(region)","as.factor(year)","cw_event_g_peaceyears_l1","I(cw_event_g_peaceyears_l1^2)","I(cw_event_g_peaceyears_l1^3)","cw_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 0 & violence_ever == 1))
viol_ever_main_m1g_t1_sf_cse <- data.frame(cluster.se(viol_ever_main_m1g_t1_sf, as.factor(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 0 & violence_ever == 1)$cowcode))[,2])
viol_ever_main_m1d_t1_sb <- glm(as.formula(paste("cv_event", paste(c(m1d_t1, dyad_nat_vars, dyad_unit_vars, unit_vars, nat_vars,"as.factor(region)","as.factor(year)","cv_event_peaceyears_l1","I(cv_event_peaceyears_l1^2)","I(cv_event_peaceyears_l1^3)","cv_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_dyad, violence_ever == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1))
viol_ever_main_m1d_t1_sb_cse <- data.frame(cluster.se(viol_ever_main_m1d_t1_sb, as.factor(subset(main_dyad, violence_ever == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode))[, 2])
viol_ever_main_m2d_t1_sb <- glm(as.formula(paste("cv_event", paste(c(m2d_t1, dyad_nat_vars, dyad_unit_vars, unit_vars, nat_vars,"as.factor(region)","as.factor(year)","cv_event_peaceyears_l1","I(cv_event_peaceyears_l1^2)","I(cv_event_peaceyears_l1^3)","cv_event_any_slag_l1"), collapse = " + "), sep = " ~ ")), family=binomial(link="logit"),control = list(maxit = 50), data=subset(main_dyad, violence_ever == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1))
viol_ever_main_m2d_t1_sb_cse <- data.frame(cluster.se(viol_ever_main_m2d_t1_sb, as.factor(subset(main_dyad, violence_ever == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode))[, 2])
stargazer(viol_ever_main_m1g_t1_sc, viol_ever_main_m1g_t1_sf, viol_ever_main_m1d_t1_sb, viol_ever_main_m2d_t1_sb, se=c(viol_ever_main_m1g_t1_sc_cse, viol_ever_main_m1g_t1_sf_cse, viol_ever_main_m1d_t1_sb_cse, viol_ever_main_m2d_t1_sb_cse), dep.var.labels.include = T, dep.var.labels = c("Civil violence (group)","Communal violence","Communal violence"), model.numbers =F, column.labels = c("Maj. (model A76)", "Min. (model A77)","Maj./min. dyad (model A78)","Maj./min. dyad (model A79)"), omit=c("cowcode|region|factor"), type="text", order=vars.order_gd, title="Table X23. Additional results: only countries that ever saw ethnic violence in the period analyzed.", style = "apsr", star.cutoffs = c(.1, .05, .01, .001), star.char = c("†", "*", "**","***"), notes = c("† p<0.1; * p<0.05; ** p<0.01; *** p<0.001; country-clustered SE’s in parentheses; maj. = second-order majority; min. = second-order minority.","The dependent variable is a binary variable equal to one if there is at least one instance of civil/communal violence involving a group/dyad in a given unit.","Region- and year-fixed effects included but not reported."), notes.append=FALSE, covariate.labels = c("Territorial autonomy","Territorial autonomy x included/excluded","Included","Included/excluded","Excluded/excluded","Relative size (state)","Relative size (state, mean)","Relative size (state, diff.)","Relative size (unit)","Relative size (unit, mean)","Relative size (unit, diff.)","Asymmetry", "Population (unit, logged)", "Area (unit, logged)", "Avg. ruggedness (unit)", "Oil in unit", "Distance capital (unit, logged)", "Distance border (unit, logged)","GDP pc. (logged)", "Population (state, logged)","Democracy","Ethnic fractionalization","Election year","Civil violence peace years","Civil violence peace years 2","Civil violence peace years 3","Civil violence spatial lag", "Communal violence peace years", "Communal violence peace years 2", "Communal violence peace years 3","Communal violence spatial lag"), out="../tables/additional_results_tables_appendices/tablex23.txt")
stargazer(viol_ever_main_m1g_t1_sc, viol_ever_main_m1g_t1_sf, viol_ever_main_m1d_t1_sb, viol_ever_main_m2d_t1_sb, se=c(viol_ever_main_m1g_t1_sc_cse, viol_ever_main_m1g_t1_sf_cse, viol_ever_main_m1d_t1_sb_cse, viol_ever_main_m2d_t1_sb_cse), dep.var.labels.include = T, dep.var.labels = c("Civil violence (group)","Communal violence","Communal violence"), model.numbers =F, column.labels = c("Maj. (model A76)", "Min. (model A77)","Maj./min. dyad (model A78)","Maj./min. dyad (model A79)"), omit=c("cowcode|region|factor"), type="html", order=vars.order_gd, title="Table X23. Additional results: only countries that ever saw ethnic violence in the period analyzed.", style = "apsr", star.cutoffs = c(.1, .05, .01, .001), star.char = c("†", "*", "**","***"), notes = c("† p<0.1; * p<0.05; ** p<0.01; *** p<0.001; country-clustered SE’s in parentheses; maj. = second-order majority; min. = second-order minority.","The dependent variable is a binary variable equal to one if there is at least one instance of civil/communal violence involving a group/dyad in a given unit.","Region- and year-fixed effects included but not reported."), notes.append=FALSE, covariate.labels = c("Territorial autonomy","Territorial autonomy x included/excluded","Included","Included/excluded","Excluded/excluded","Relative size (state)","Relative size (state, mean)","Relative size (state, diff.)","Relative size (unit)","Relative size (unit, mean)","Relative size (unit, diff.)","Asymmetry", "Population (unit, logged)", "Area (unit, logged)", "Avg. ruggedness (unit)", "Oil in unit", "Distance capital (unit, logged)", "Distance border (unit, logged)","GDP pc. (logged)", "Population (state, logged)","Democracy","Ethnic fractionalization","Election year","Civil violence peace years","Civil violence peace years 2","Civil violence peace years 3","Civil violence spatial lag", "Communal violence peace years", "Communal violence peace years 2", "Communal violence peace years 3","Communal violence spatial lag"), out="../tables/additional_results_tables_appendices/tablex23.html")

####Figure A14####
##a) segmented clientelistic (civil)
me_r5b_m1g_t1_sc <- margins_summary(r5b_m1g_t1_sc, variables = "sa_territory_t", vcov = cluster.vcov(r5b_m1g_t1_sc, as.integer(subset(main_group, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant_g == 1)$cowcode)))
me_r5b_m1g_t1_sc$term <- "second-order maj."
me_r5b_m1g_t1_sf <- margins_summary(r5b_m1g_t1_sf, variables = "sa_territory_t", vcov = cluster.vcov(r5b_m1g_t1_sf, as.integer(subset(main_group, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant_g == 0)$cowcode)))
me_r5b_m1g_t1_sf$term <- "second-order min."
me_r5b_m1g <- rbind.fill(me_r5b_m1g_t1_sc, me_r5b_m1g_t1_sf)
me_r5b_m1g$term <- as.factor(me_r5b_m1g$term)
me_r5b_m1g$term = factor(me_r5b_m1g$term,levels(me_r5b_m1g$term)[c(2,1)])
me_r5b_m1g$model <- "subsample: segmented clientelistic"
me_r5b_m1g$estimate <- me_r5b_m1g$AME
me_r5b_m1g$conf.low <- me_r5b_m1g$lower
me_r5b_m1g$conf.high <- me_r5b_m1g$upper
##b) segmented clientelistic (communal)
me_r5b_m1d_t1_sb <- margins_summary(r5b_m1d_t1_sb, variables = "sa_territory_t", vcov = cluster.vcov(r5b_m1d_t1_sb, as.integer(subset(main_dyad, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode)))
me_r5b_m1d_t1_sb$term <- "all"
me_r5b_m1d_t1_sb$model <- "subsample: segmented clientelistic"
me_r5b_m2d_t1_sb <- margins_summary(r5b_m2d_t1_sb, variables = "sa_territory_t", at = list(included_excluded = c(0,1)), vcov = cluster.vcov(r5b_m2d_t1_sb, as.integer(subset(main_dyad, sample_segmented_clientelistic == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode)))
me_r5b_m2d_t1_sb$term <- ifelse(me_r5b_m2d_t1_sb$included_excluded == 1, "included/excluded", "other")
me_r5b_m2d_t1_sb$model <- "subsample: segmented clientelistic"
me_r5b_m13d <- rbind.fill(me_r5b_m1d_t1_sb, me_r5b_m2d_t1_sb)
me_r5b_m13d <- subset(me_r5b_m13d, term != "other")
me_r5b_m13d$term <- as.factor(me_r5b_m13d$term)
me_r5b_m13d$estimate <- me_r5b_m13d$AME
me_r5b_m13d$conf.low <- me_r5b_m13d$lower
me_r5b_m13d$conf.high <- me_r5b_m13d$upper
##c) democracies (civil)
me_dem_main_m1g_t1_sc <- margins_summary(dem_main_m1g_t1_sc, variables = "sa_territory_t", vcov = cluster.vcov(dem_main_m1g_t1_sc, as.integer(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 1 & politya >= 0.8)$cowcode)))
me_dem_main_m1g_t1_sc$term <- "second-order maj."
me_dem_main_m1g_t1_sf <- margins_summary(dem_main_m1g_t1_sf, variables = "sa_territory_t", vcov = cluster.vcov(dem_main_m1g_t1_sf, as.integer(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 0 & politya >= 0.8)$cowcode)))
me_dem_main_m1g_t1_sf$term <- "second-order min."
me_dem_main <- rbind.fill(me_dem_main_m1g_t1_sc, me_dem_main_m1g_t1_sf)
me_dem_main$term <- as.factor(me_dem_main$term)
me_dem_main$term = factor(me_dem_main$term,levels(me_dem_main$term)[c(2,1)])
me_dem_main$model <- "subsample: democracies"
me_dem_main$estimate <- me_dem_main$AME
me_dem_main$conf.low <- me_dem_main$lower
me_dem_main$conf.high <- me_dem_main$upper
##d) democracies (communal)
me_dem_main_m1d_t1_sb <- margins_summary(dem_main_m1d_t1_sb, variables = "sa_territory_t", vcov = cluster.vcov(dem_main_m1d_t1_sb, as.integer(subset(main_dyad, politya >= 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode)))
me_dem_main_m1d_t1_sb$term <- "all"
me_dem_main_m1d_t1_sb$model <- "subsample: democracies"
me_dem_main_m2d_t1_sb <- margins_summary(dem_main_m2d_t1_sb, variables = "sa_territory_t", at = list(included_excluded = c(0,1)), vcov = cluster.vcov(dem_main_m2d_t1_sb, as.integer(subset(main_dyad, politya >= 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode)))
me_dem_main_m2d_t1_sb$term <- ifelse(me_dem_main_m2d_t1_sb$included_excluded == 1, "included/excluded", "other")
me_dem_main_m2d_t1_sb$model <- "subsample: democracies"
me_dem_main_d <- rbind.fill(me_dem_main_m1d_t1_sb, me_dem_main_m2d_t1_sb)
me_dem_main_d <- subset(me_dem_main_d, term != "other")
me_dem_main_d$term <- as.factor(me_dem_main_d$term)
me_dem_main_d$estimate <- me_dem_main_d$AME
me_dem_main_d$conf.low <- me_dem_main_d$lower
me_dem_main_d$conf.high <- me_dem_main_d$upper
##e) autocracies (civil)
me_aut_main_m1g_t1_sc <- margins_summary(aut_main_m1g_t1_sc, variables = "sa_territory_t", vcov = cluster.vcov(aut_main_m1g_t1_sc, as.integer(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 1 & politya < 0.8)$cowcode)))
me_aut_main_m1g_t1_sc$term <- "second-order maj."
me_aut_main_m1g_t1_sf <- margins_summary(aut_main_m1g_t1_sf, variables = "sa_territory_t", vcov = cluster.vcov(aut_main_m1g_t1_sf, as.integer(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 0 & politya < 0.8)$cowcode)))
me_aut_main_m1g_t1_sf$term <- "second-order min."
me_aut_main <- rbind.fill(me_aut_main_m1g_t1_sc, me_aut_main_m1g_t1_sf)
me_aut_main$term <- as.factor(me_aut_main$term)
me_aut_main$term = factor(me_aut_main$term,levels(me_aut_main$term)[c(2,1)])
me_aut_main$model <- "subsample: autocracies"
me_aut_main$estimate <- me_aut_main$AME
me_aut_main$conf.low <- me_aut_main$lower
me_aut_main$conf.high <- me_aut_main$upper
##f) autocracies (communal)
me_aut_main_m1d_t1_sb <- margins_summary(aut_main_m1d_t1_sb, variables = "sa_territory_t", vcov = cluster.vcov(aut_main_m1d_t1_sb, as.integer(subset(main_dyad, politya < 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode)))
me_aut_main_m1d_t1_sb$term <- "all"
me_aut_main_m1d_t1_sb$model <- "subsample: autocracies"
me_aut_main_m2d_t1_sb <- margins_summary(aut_main_m2d_t1_sb, variables = "sa_territory_t", at = list(included_excluded = c(0,1)), vcov = cluster.vcov(aut_main_m2d_t1_sb, as.integer(subset(main_dyad, politya < 0.8 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode)))
me_aut_main_m2d_t1_sb$term <- ifelse(me_aut_main_m2d_t1_sb$included_excluded == 1, "included/excluded", "other")
me_aut_main_m2d_t1_sb$model <- "subsample: autocracies"
me_aut_main_d <- rbind.fill(me_aut_main_m1d_t1_sb, me_aut_main_m2d_t1_sb)
me_aut_main_d <- subset(me_aut_main_d, term != "other")
me_aut_main_d$term <- as.factor(me_aut_main_d$term)
me_aut_main_d$estimate <- me_aut_main_d$AME
me_aut_main_d$conf.low <- me_aut_main_d$lower
me_aut_main_d$conf.high <- me_aut_main_d$upper
##g) ever violent (civil)
me_viol_ever_main_m1g_t1_sc <- margins_summary(viol_ever_main_m1g_t1_sc, variables = "sa_territory_t", vcov = cluster.vcov(viol_ever_main_m1g_t1_sc, as.integer(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 1 & violence_ever == 1)$cowcode)))
me_viol_ever_main_m1g_t1_sc$term <- "second-order maj."
me_viol_ever_main_m1g_t1_sf <- margins_summary(viol_ever_main_m1g_t1_sf, variables = "sa_territory_t", vcov = cluster.vcov(viol_ever_main_m1g_t1_sf, as.integer(subset(main_group, subset_analysis == 1 & int_grp_rel_dominant_g == 0 & violence_ever == 1)$cowcode)))
me_viol_ever_main_m1g_t1_sf$term <- "second-order min."
me_viol_ever_main <- rbind.fill(me_viol_ever_main_m1g_t1_sc, me_viol_ever_main_m1g_t1_sf)
me_viol_ever_main$term <- as.factor(me_viol_ever_main$term)
me_viol_ever_main$term = factor(me_viol_ever_main$term,levels(me_viol_ever_main$term)[c(2,1)])
me_viol_ever_main$model <- "subsample: ever violent"
me_viol_ever_main$estimate <- me_viol_ever_main$AME
me_viol_ever_main$conf.low <- me_viol_ever_main$lower
me_viol_ever_main$conf.high <- me_viol_ever_main$upper
##h) ever violent (communal)
me_viol_ever_main_m1d_t1_sb <- margins_summary(viol_ever_main_m1d_t1_sb, variables = "sa_territory_t", vcov = cluster.vcov(viol_ever_main_m1d_t1_sb, as.integer(subset(main_dyad, violence_ever == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode)))
me_viol_ever_main_m1d_t1_sb$term <- "all"
me_viol_ever_main_m1d_t1_sb$model <- "subsample: ever violent"
me_viol_ever_main_m2d_t1_sb <- margins_summary(viol_ever_main_m2d_t1_sb, variables = "sa_territory_t", at = list(included_excluded = c(0,1)), vcov = cluster.vcov(viol_ever_main_m2d_t1_sb, as.integer(subset(main_dyad, violence_ever == 1 & subset_analysis == 1 & int_grp_rel_dominant == 1)$cowcode)))
me_viol_ever_main_m2d_t1_sb$term <- ifelse(me_viol_ever_main_m2d_t1_sb$included_excluded == 1, "included/excluded", "other")
me_viol_ever_main_m2d_t1_sb$model <- "subsample: ever violent"
me_viol_ever_main_d <- rbind.fill(me_viol_ever_main_m1d_t1_sb, me_viol_ever_main_m2d_t1_sb)
me_viol_ever_main_d <- subset(me_viol_ever_main_d, term != "other")
me_viol_ever_main_d$term <- as.factor(me_viol_ever_main_d$term)
me_viol_ever_main_d$estimate <- me_viol_ever_main_d$AME
me_viol_ever_main_d$conf.low <- me_viol_ever_main_d$lower
me_viol_ever_main_d$conf.high <- me_viol_ever_main_d$upper
##i) combined (civil)
subsample_plot_data_g <- rbind.fill(me_r5b_m1g,me_dem_main,me_aut_main,me_viol_ever_main)
subsample_plot_data_g$model <- as.factor(subsample_plot_data_g$model)
subsample_plot_data_g$term <- as.factor(subsample_plot_data_g$term)
subsample_plot_data_g$term = factor(subsample_plot_data_g$term,levels(subsample_plot_data_g$term)[c(2,1)])
subsample_plot_g <- dwplot(subsample_plot_data_g,vline = geom_vline(xintercept = 0, colour = "grey60", linetype = 2),dot_args = list(aes(colour = model,shape =model)), whisker_args = list(linetype = 1, aes(colour = model))) +
  theme_bw() + theme(plot.title = element_text(size=12)) + xlab("Coefficient estimate") + ylab("") +
  geom_vline(xintercept = 0, colour = "grey60", linetype = 2) +
  ggtitle("a) civil violence") +
  scale_color_manual(name = "Coefficient for:", values = c("#7fc97f","#beaed4","#fdc086","#386cb0"))+ scale_linetype_manual(name = "Coefficient for:", values = c(4,3,2,1))+ scale_shape_manual(name = "Coefficient for:", values = c(16,17,18,20))+ 
  theme(plot.title.position = "plot",legend.position = "bottom", text=element_text(family="Times"), axis.title=element_text(size=10), legend.text=element_text(size=10)) + 
  xlab("change in predicted prob.\n of civil violence") + ylab("group type")+
  guides(shape = guide_legend(nrow=2,"model",reverse=TRUE), colour = guide_legend(nrow=2,"model",reverse=TRUE),linetype = guide_legend(nrow=2,"model",reverse=TRUE)) +
  scale_x_continuous(labels=scales::percent_format(), breaks = c(-0.03, -0.015, 0))
##j) combined (communal)
subsample_plot_data_d <- rbind.fill(me_r5b_m13d,me_dem_main_d,me_aut_main_d,me_viol_ever_main_d)
subsample_plot_data_d$model <- as.factor(subsample_plot_data_d$model)
subsample_plot_d <- dwplot(subsample_plot_data_d,vline = geom_vline(xintercept = 0, colour = "grey60", linetype = 2),dot_args = list(aes(colour = model,shape =model)), whisker_args = list(linetype = 1, aes(colour = model))) +
  theme_bw() + theme(plot.title = element_text(size=12)) + xlab("Coefficient estimate") + ylab("") +
  geom_vline(xintercept = 0, colour = "grey60", linetype = 2) +
  ggtitle("b) communal violence maj./min. dyad") +
  scale_color_manual(name = "Coefficient for:", values = c("#7fc97f","#beaed4","#fdc086","#386cb0"))+ scale_linetype_manual(name = "Coefficient for:", values = c(4,3,2,1))+ scale_shape_manual(name = "Coefficient for:", values = c(16,17,18,20))+ 
  theme(plot.title.position = "plot",legend.position = "bottom", text=element_text(family="Times"), axis.title=element_text(size=10), legend.text=element_text(size=10)) + 
  guides(shape = guide_legend(nrow=2,"model",reverse=TRUE), colour = guide_legend(nrow=2,"model",reverse=TRUE),linetype = guide_legend(nrow=2,"model",reverse=TRUE)) +
  scale_x_continuous(labels=scales::percent_format(), breaks =c(0, 0.003, 0.006))
##k) combined
figurea14 <- grid_arrange_shared_legend(subsample_plot_g, subsample_plot_d, ncol=2, nrow=1)
ggsave(figurea14, file='../figures/figurea14.pdf', width = 14, height = 6.5, units="cm",dpi=1000)